import * as echarts from 'echarts'

/**
 * 基础柱状图
 * @param el
 * @param params
 * @author 赵京涛
 */
export const useBarEchartsHandler = (el, params) => {
  const myChart = echarts.init(el)
  const option = {
    title: {
      subtext: 'ug/m³',
      subtextStyle: {
        color: '#1f8df3'
      }
    },
    xAxis: {
      type: 'category',
      data: params.xData,
      axisLabel: {
        textStyle: {
          color: '#1f8df3',
          fontSize: 10
        }
      },
      axisLine: {
        show: true,
        lineStyle: {
          color: '#1f8df3',
          width: 1
        }
      }
    },
    tooltip: {
      trigger: 'axis',
      formatter: '{b}: {c}'
    },
    grid: {
      left: '3%',
      right: '3%',
      top: '20%',
      bottom: '3%',
      containLabel: true
    },
    yAxis: {
      type: 'value',
      axisLabel: {
        textStyle: {
          color: '#1f8df3'
        }
      },
      axisLine: {
        show: true,
        lineStyle: {
          color: '#1f8df3',
          width: 1
        }
      }
    },
    color: ['#1fb227'],
    series: params.seriesData
  }
  option && myChart.setOption(option)
}
